package com.cowin.sys.controller;

import com.cowin.base.BaseController;
import com.cowin.base.result.Result;
import com.cowin.base.result.ResultGenerator;
import com.cowin.sys.model.TmBasSubmitOrder;
import com.cowin.sys.model.vo.CYSubmitOrderVo;
import com.cowin.sys.model.vo.TmBasSubmitOrderVo;
import com.cowin.sys.service.TmBasSubmitOrderService;
import io.swagger.annotations.ApiOperation;

import java.util.List;
import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"/tm/bas/submit/order"})
public class TmBasSubmitOrderController extends BaseController<TmBasSubmitOrder> {
    private static final Logger log = LoggerFactory.getLogger(com.cowin.sys.controller.TmBasSubmitOrderController.class);

    @Resource
    private TmBasSubmitOrderService tmBasSubmitOrderService;

    @ApiOperation(value = ", notes = ")
    @PostMapping({"/dateForm"})
    public Result getDateForm(@RequestBody CYSubmitOrderVo cySubmitOrderVo) {
        if (cySubmitOrderVo.getDateTime() == null) {
            return ResultGenerator.genFailResult("请选择时间");
        }
        List<CYSubmitOrderVo> list = this.tmBasSubmitOrderService.getDateForm(cySubmitOrderVo);
        return ResultGenerator.genSuccessResult(list);
    }

    @ApiOperation(value = ", notes = ")
    @PostMapping({"/isSubmit"})
    public Result getDateFormInfo(@RequestBody TmBasSubmitOrderVo tmBasSubmitOrderVo) {
        if (tmBasSubmitOrderVo.getBeginDate() == null || tmBasSubmitOrderVo.getEndDate() == null) {
            return ResultGenerator.genFailResult("请选择时间");
        }
        List<TmBasSubmitOrderVo> list = this.tmBasSubmitOrderService.getDateFormInfo(tmBasSubmitOrderVo);
        return ResultGenerator.genSuccessResult(list);
    }
}
